package cn.miju.common.exception;

import cn.miju.common.content.CodeMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <pre>
 * 参数类校验异常
 * </pre>
 *
 * @author zhuming
 * @version 1.0.0
 * @since 2023-03-01 15:30
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ValidateException extends RuntimeException {
    private Integer code;
    private String message;

    public ValidateException() {
        super();
    }

    public ValidateException(String message) {
        super(message);
        this.code = CodeMessage.VALIDATE_FAIL.getCode();
        this.message = message;
    }

    public ValidateException(String message, Throwable cause) {
        super(message, cause);
        this.code = CodeMessage.VALIDATE_FAIL.getCode();
        this.message = message;
    }

    public ValidateException(Throwable cause) {
        super(cause);
        this.code = CodeMessage.VALIDATE_FAIL.getCode();
        this.message = cause.getMessage();
    }

    public ValidateException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = CodeMessage.VALIDATE_FAIL.getCode();
        this.message = message;
    }

}
